package net.wing.demo.dao;


import com.alibaba.fastjson.JSONObject;
import net.wing.demo.dao.row.MessageRow;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;

/**
 * @Author beifengtz
 * @Date Created in 9:00 2018/8/10
 * @Description:
 */
@Repository
public class MessageMapper {

    @Autowired
    private JdbcTemplate jdbcTemplate;

    /**
     * @Author beifengtz
     * @Date Created in 2018/8/10 9:07
     * @Description:    查询所有留言信息的数据持久层
     * @param none
     * @return List
     */
    public ArrayList selectAllMessage(){
        String sql = "select * from message_tb";
        return (ArrayList) jdbcTemplate.query(sql,new MessageRow());
    }

    public int insertMessage(String content, int date) {
        String sql = "insert into message_tb(message_content,message_date) values(?,?)";
        return jdbcTemplate.update(sql,new Object[] {content,date});
    }
}
